import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { h } from 'vue';
import { Switch } from 'ant-design-vue';
import { setRoleStatus } from '/@/api/demo/system';
import { useMessage } from '/@/hooks/web/useMessage';
import { useI18n } from '/@/hooks/web/useI18n';
import { defHttp } from '/@/utils/http/axios';
enum Api {
  PageList = '/system/${entity?uncap_first}/listByPage',
  Add = '/system/${entity?uncap_first}/add',
  Edit = '/system/${entity?uncap_first}/edit',
  Delete = '/system/${entity?uncap_first}/delete?id=',
}
const { t } = useI18n();
// 
export const getListByPage = (params?: any) =>
  defHttp.get<any>({ url: Api.PageList, params });
// 
export const add${entity} = (params?: any) => {
  return defHttp.post<any>({ url: Api.Add, params });
}

export const edit${entity} = (params?: any) => {
  return defHttp.put<any>({ url: Api.Edit, params });
}

/**
 * 删除字典
 */
export const delete${entity} = (id, handleSuccess) => {
  return defHttp.delete({ url: Api.Delete + id}).then(() => {
    handleSuccess();
  });
}

export const columns: BasicColumn[] = [
<#list table.fields as field>
  {
    title: '${field.comment}',
    dataIndex: '${field.propertyName}',
    width: 200,
  },
</#list>
];

export const searchFormSchema: FormSchema[] = [
<#list table.fields as field>
  {
    field: '${field.propertyName}',
    label: '${field.comment}',
    component: 'Input',
    colProps: { span: 8 },
  },
</#list>
];

export const formSchema: FormSchema[] = [
<#list table.fields as field>
  {
    field: '${field.propertyName}',
    label: '${field.comment}',
    required: true,
    component: 'Input',
  },
</#list>
];

